package thread;
class MyThread3 implements Runnable{//Runnable可以理解成可执行的,通过这个接口,就可以抽象出可以被其他实体来执行的代码
    @Override
    public void run() {
        while (true){
            System.out.println("hello runnable");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

    }
}
public class ThreadDemo3 {
    public static void main(String[] args) throws InterruptedException {
        Runnable runnable = new MyThread3();
        Thread t = new Thread(runnable);
        //Thread t = new Thread(new MyThread3());
        t.start();
        while (true){
            System.out.println("hello main");
            Thread.sleep(1000);
        }

    }
}
